package com.ebrothers.isns.map.ovarlay;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;

import com.ebrothers.isns.R;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class MyLocationOverlay extends Overlay {
	private GeoPoint mPoint;
	private Context mContext;

	public MyLocationOverlay(Context context) {
		mContext = context;
	}

	public void moveTo(GeoPoint point) {
		mPoint = point;
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		if (mPoint != null) {
			Projection projection = mapView.getProjection();
			Point point = new Point();
			projection.toPixels(mPoint, point);
			Bitmap bitmap = BitmapFactory.decodeResource(
					mContext.getResources(), R.drawable.pin_venue);
			canvas.drawBitmap(bitmap, point.x - bitmap.getWidth(), point.y
					- bitmap.getHeight(), null);
		}
		super.draw(canvas, mapView, shadow);
	}
}
